-
Notifications
You must be signed in to change notification settings - Fork 559
Add sdk.Context and vm.EVM to precompiles #1433
Add sdk.Context and vm.EVM to precompiles #1433
Conversation
Add context to precompiles: both Cosmos `sdk.Context` and `vm.EVM`. vm.EVM provides block, tx, along with state access. And if this PR ethereum/go-ethereum#26119 is merged, it will also provide current call/subcall context.
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1433 +/- ##
==========================================
+ Coverage 57.59% 57.67% +0.07%
==========================================
Files 108 108
Lines 10087 10095 +8
==========================================
+ Hits 5810 5822 +12
+ Misses 4031 4029 -2
+ Partials 246 244 -2
|
// custom stateless precompiled smart contracts | ||
customPrecompiles evm.PrecompiledContracts | ||
// Precompile extensions | ||
getPrecompilesExtended func(ctx sdk.Context, evm *vm.EVM) evm.PrecompiledContracts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could make this function take an address and return a singular precompile. Opens up more modularity.
x/evm/vm/geth/geth.go
Outdated
func (EVM) ActivePrecompiles(rules params.Rules) []common.Address { | ||
return vm.ActivePrecompiles(rules) | ||
func (e EVM) ActivePrecompiles(rules params.Rules) []common.Address { | ||
// TODO e.precompiles |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This requires a geth fork right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this (will return to this when I have some time later today)ActivePrecompiles
is not actually used now. I changed it when I was testing and forgot to revert the changes. For clarity, I will remove them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ethermint uses its own ActivePrecompiles
function in state_transition.go
. The only other places I've seen vm.ActivePrecompiles
used in go-ethereum is tracer-related.
marking this as Draft until we have more clarity on the final implementation |
Description
Add context to precompiles: both Cosmos
sdk.Context
andvm.EVM
.vm.EVM provides block, tx, along with state access.
And if this PR ethereum/go-ethereum#26119 is merged, it will also provide current call/subcall context.
Related: #1131
For contributor use:
docs/
) or specification (x/<module>/spec/
)godoc
comments.Unreleased
section inCHANGELOG.md
Files changed
in the Github PR explorerFor admin use:
WIP
,R4R
,docs
, etc)